/*
 * Name: Minh-Tuan ta
 * Class: DeleteComment.java
 */

package actions;

import java.io.IOException;
import java.sql.Date;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import beans.Comment;
import beans.User;
import data.CommentDB;
import data.ContentTypeDB;

public class DeleteComment extends Action {

	@Override
	protected void setURLMapping() {
		// TODO Auto-generated method stub
		urlMapping = "/DeleteComment";
	}

	@Override
	protected String doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	protected String doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		HttpSession session = request.getSession();
		String url = getLastURL(request, session);
		
		int commentID = Integer.parseInt(request.getParameter("commentID"));
		Comment comment = new Comment();
		comment.setContentID(commentID);
		
		if (CommentDB.deleteComment(comment) == 1)
		{
			session.setAttribute("ReturnStatus", "Comment Deleted");
		}
		else
		{
			session.setAttribute("ReturnStatus", "Comment Not Deleted");
		}
		
		return url;
	}

	@Override
	protected void setupPage(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		
	}
}
